<template>
  <div class="clock-management">
    <el-tabs type="border-card">
      <el-tab-pane label="考勤管理">
        <div class="search">
          <el-input
            v-model="queryInfo.name"
            placeholder="姓名"
            clearable
            @input="getLeaveList"
          ></el-input>

          <el-date-picker
            v-model="queryInfo.date_time"
            type="date"
            placeholder="选择日期"
          >
          </el-date-picker>
        </div>
        <el-table :data="tableData" style="width: 100%">
          <el-table-column type="selection" width="45"> </el-table-column>
          <el-table-column
            type="index"
            :index="1 + (queryInfo.page - 1) * queryInfo.size"
            label="编号"
            width="60"
          >
          </el-table-column>
          <el-table-column prop="name" label="姓名"></el-table-column>
          <el-table-column prop="duty_time" label="打卡时间">
          </el-table-column>
          <el-table-column prop="end_time" label="结束时间"> </el-table-column>
          <el-table-column
            prop="leaveType"
            label="请假类型"
            width="100"
          >
            <template slot-scope="scope" v-if="scope.row.leaveType">
              <el-tag disable-transitions>{{ scope.row.leaveType }}</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="remarks" label="请假事由" width="160">
          </el-table-column>

          <el-table-column prop="create_time" label="申请时间">
          </el-table-column>
          <el-table-column label="操作" width="180">
            <template slot-scope="scope">
              <el-button
                size="mini"
                @click="handleEdit(scope.$index, scope.row)"
                >同意</el-button
              >
              <el-button
                size="mini"
                type="danger"
                @click="handleDelete(scope.$index, scope.row)"
                >拒绝</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页组件 -->
        <div class="pagination">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="queryInfo.page"
            :page-sizes="[2, 5, 7, 10]"
            :page-size="queryInfo.size"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
          >
          </el-pagination>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
  
<script>
import { getClockList } from "@/api/user";
export default {
  data() {
    return {
      //查询信息实体
      queryInfo: {
        name: "",
        page: 1, //当前页
        size: 10, //每页最大数
      },
      total: 10,
      user: {
        avatar: "",
      },
      tableData: [],
    };
  },
  methods: {
    getClockData() {
      getClockList(this.queryInfo).then((res)=>{
        this.tableData = res.data;
        this.total = res.total;
      })
    },
    //最大数
    handleSizeChange(newSize) {
      this.queryInfo.size = newSize;
      this.getVip();
    },
    //pageNum的触发动作
    handleCurrentChange(newPage) {
      this.queryInfo.page = newPage;
      this.getVip();
    }
  },
  created() {
    this.getClockData();
  },
};
</script>
  
  <style lang="less" scoped>
.leave-management {
  margin: 0 16px;

  .pagination {
    width: 400px;
    margin: 10px auto;
  }

  .search {
    .el-input {
      width: 150px;
      margin-right: 20px;
      margin-bottom: 20px;
    }
  }
}
</style>
  